package com.struts2.action;

import java.util.List;
import java.util.Map;

import org.apache.struts2.interceptor.SessionAware;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.struts2.model.Category;
import com.struts2.model.Color;
import com.struts2.model.Designer;
import com.struts2.model.Gender;
import com.struts2.model.Product_item;
import com.struts2.model.Product_line;
import com.struts2.model.Season;
import com.struts2.model.Size;
import com.struts2.model.Type;
import com.struts2.service.AdminService;

public class AdminProductItemAction extends ActionSupport implements ModelDriven<Product_item>,SessionAware{

	
	
	// For SessionAware
	private Map<String, Object> session;

	@Override
	public void setSession(Map<String, Object> session) {
		this.session = session;
	}

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private Product_item product_item;
	private List<Color> colorList;
	private List<Product_line> product_lineList;
	private List<Size> sizeList;
	
	private Product_line product_line;
	private List<Product_item> product_items;


	private int yourProduct_line;
	private int yourColor;
	private int yourSize;
	private int quantity;
	private int approval;
	
	
	private int id;
	
	public String execute() {
		AdminService as = new AdminService();
		
		product_item = as.getProduct_item(id);
		
		product_lineList = as.getProduct_lineList();
		colorList = as.getColorList();
		sizeList = as.getSizeList();
		
		System.out.print(yourSize);
		
		return SUCCESS;
	}


	
	public String Save()
	{
		
		AdminService as = new AdminService();
		as.setProduct_Item(id,yourProduct_line,yourColor,yourSize,quantity,approval);
		
		id = yourProduct_line;
		product_line = as.getProduct_line(id);
		setProduct_items(as.getProduct_items(product_line));
		
		int num= as.getProductNotApproval();
		session.put("productsNotApproval", num);
		
		
		return SUCCESS;
	}



	
	@Override
	public Product_item getModel() {
		// TODO Auto-generated method stub
		return null;
	}
	
	
	
	

	// /************************************************************************************************************

	public Product_item getProduct_item() {
		return product_item;
	}



	public void setProduct_item(Product_item product_item) {
		this.product_item = product_item;
	}



	public int getId() {
		return id;
	}



	public void setId(int id) {
		this.id = id;
	}



	public List<Color> getColorList() {
		return colorList;
	}



	public void setColorList(List<Color> colorList) {
		this.colorList = colorList;
	}



	public List<Product_line> getProduct_lineList() {
		return product_lineList;
	}



	public void setProduct_lineList(List<Product_line> product_lineList) {
		this.product_lineList = product_lineList;
	}



	public List<Size> getSizeList() {
		return sizeList;
	}



	public void setSizeList(List<Size> sizeList) {
		this.sizeList = sizeList;
	}







	public int getQuantity() {
		return quantity;
	}



	public void setQuantity(int quantity) {
		this.quantity = quantity;
	}



	public int getApproval() {
		return approval;
	}



	public void setApproval(int approval) {
		this.approval = approval;
	}



	public int getYourProduct_line() {
		return yourProduct_line;
	}



	public void setYourProduct_line(int yourProduct_line) {
		this.yourProduct_line = yourProduct_line;
	}



	public int getYourColor() {
		return yourColor;
	}



	public void setYourColor(int yourColor) {
		this.yourColor = yourColor;
	}



	public int getYourSize() {
		return yourSize;
	}



	public void setYourSize(int yourSize) {
		this.yourSize = yourSize;
	}



	public List<Product_item> getProduct_items() {
		return product_items;
	}



	public void setProduct_items(List<Product_item> product_items) {
		this.product_items = product_items;
	}



	public Product_line getProduct_line() {
		return product_line;
	}



	public void setProduct_line(Product_line product_line) {
		this.product_line = product_line;
	}



	

	// *//////////////////////////////////////
	
}
